package com.gonsin.gview.example.groovy.bean

import com.gonsin.gview.annotations.GView
import com.gonsin.gview.annotations.board.GBoard
import com.gonsin.gview.annotations.board.GButton
import com.gonsin.gview.annotations.board.form.GTextInput
import com.gonsin.gview.annotations.board.table.GColumn
import com.gonsin.gview.annotations.board.table.GHeader
import com.gonsin.gview.annotations.board.table.GSearchBar
import com.gonsin.gview.annotations.board.table.GSearchFilter
import com.gonsin.gview.annotations.board.table.GTable
import com.gonsin.gview.annotations.data.GTableData
import com.gonsin.gview.annotations.enums.ButtonAction
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
import lombok.Data

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table


@GView(
        viewName = "UserBean",
        title = "账户管理",
        boards = @GBoard(table = @GTable(
                tableData = @GTableData(fromDataSource = "searchUser", keyName = "userId"),
                header = @GHeader(
                        buttons = [
                            @GButton(name = "按钮1", action = ButtonAction.NONE),
                            @GButton(name = "按钮2", action = ButtonAction.NONE)
                        ],
                        searchBar = @GSearchBar(filters = @GSearchFilter(textInput = @GTextInput(name = "用户名", keyName = "username")))
                ),
                columns = [
                    @GColumn(name = "用户id", keyName = "userId"),
                    @GColumn(name = "用户名", keyName = "username"),
                    @GColumn(name = "密码", keyName = "password"),
                ]
        ))
)

@Entity
@Table(name = "gview_user")
@Data
@ApiModel("账户表")
class UserBean {

    @ApiModelProperty("用户主键")
    @Column(name = "user_id", columnDefinition = "varchar(64) comment '用户名'")
    @Id
    private String userId;

    @ApiModelProperty("用户名")
    @Column(name = "username", columnDefinition = "varchar(64) comment '用户名' ")
    private String username;

    @ApiModelProperty("密码")
    @Column(name = "password", columnDefinition = "varchar(64) comment '密码' ")
    private String password;

}
